import time
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdrivermanager_cn import ChromeDriverManager  #内置了国内的镜像源
#from webdriver_manager.chrome import ChromeDriverManager
#安装驱动
ChromeIns=ChromeDriverManager().install()

# 可选配置
options = Options()
options.add_argument("--start-maximized")

#启动浏览器
driver=webdriver.Chrome(service=Service(ChromeIns),options=options)
driver.get("https://www.baidu.com/")
##搜索栏填写，消除，再填写，防止并接
driver.find_element(By.CSS_SELECTOR,"#kw").send_keys("12235345645645")
driver.find_element(By.CSS_SELECTOR,"#su").click()
driver.find_element(By.CSS_SELECTOR,"#kw").clear()
# time.sleep(1)
driver.find_element(By.CSS_SELECTOR,"#kw").send_keys("12235345645645")
driver.find_element(By.CSS_SELECTOR,"#su").click()
time.sleep(7)
# time.sleep(2)
# driver.find_element(By.CSS_SELECTOR,"#kw").clear()
# time.sleep(2)
# driver.find_element(By.CSS_SELECTOR,"#kw").send_keys("456")
# time.sleep(2)
##找到对应元素的文本导出来
#text=driver.find_element(By.CSS_SELECTOR,"#hotsearch-content-wrapper > li:nth-child(2) > a > span.title-content-title").text
#print(text)
#assert text=="女生输头孢离世家属与医院和解"
#